let myName:string="lilei";
console.log(myName);
console.log(myName+"22");

class Student {
    fullName: string;
    constructor(public firstName:string, public middleInitial:string, public lastName:string) {
        this.fullName = firstName + " " + middleInitial + " " + lastName;
    }
}

interface Person {
    firstName: string;
    lastName: string;
}

function greeter(person : Person) {
    return "Hello, " + person.firstName + " " + person.lastName;
}

let user = new Student("Jane", "M.", "User");

console.log(user)
console.log(user.fullName)

// 声明一个元组类型
let x:[string,number];
// 初始化it
x=['hello',10]; // OK

// 初始化it不正确
// x=[10,'hello']; // Error

console.log(x[0].substring(1));


// x[3]='world'; // Ok，字符串可以赋值给(string|number)类型
// console.log(x[3]=='Best')

enum Color { Green,Blue,Red}

class Greeter{
    greeting:string;
    constructor(message:string){
        this.greeting=message;
    }
    greet(){
        return "Hello"+this.greeting+Color[Color.Blue];
    }
}

let greeter1=new Greeter("world");
console.log(greeter1.greet())

class Animal{
    // move(){
    //     console.log("Animal move");
    // };
    move(distance:number=0){
        console.log(`Animal moved ${distance}m.`)
    }
}

class Dog extends Animal{
    bark(){
        console.log('Woof! Woof!');
    }

    move(distance:number=0){
        console.log(`Dog move ${distance}`);
    }
}

const dog=new Dog();
dog.bark();
dog.move(101);
dog.bark();

// function g(){
//     return 
// }

function f(){
    var a=1;
    a=2;
    var b=g();
    a=3;

    return b;

    function g(){
        return a;
    }
}
console.log(f());

function f1(shouldInitialize: boolean) {
    var x21;
    if (shouldInitialize) {
        x21 = 10;
    }

    return x21;
}

console.log(f1(true));  // returns '10'
console.log(f1(false)); // returns 'undefined'

for (var i = 0; i < 10; i++) {
    setTimeout(function() { console.log(i); }, 100 * i);
}

// 学历不限  
// 初中及以上  
// 中专/中技及以上  
// 高中及以上  
// 大专及以上  
// 本科及以上  
// 硕士及以上  
// 博士及以上  
// 博士后
